<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Output Class - Fuel Documentation</title>
	<link href="../assets/css/main.css" media="screen" rel="stylesheet" />
	<script type="text/javascript" src="../assets/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="../assets/js/nav.js"></script>
	<script type="text/javascript" src="../assets/js/highlight.pack.js"></script>
	<script type="text/javascript">
		$(function() {
			show_nav('classes', '../');
		});
		hljs.tabReplace = '    ';
		hljs.initHighlightingOnLoad();
	</script>
</head>
<body>

	<header>
		<h1>FUEL Documentation</h1>
	</header>

	<div id="main-nav"></div>

	<section id="content">
		<h2>Output Class</h2>

		<p>The output class contains the methods to deal with HTTP header information.</p>

		<article>
			<h4>Setting the Status Header</h4>
			<p>The status header is treated as a &quot;special&quot; header in Fuel.  You do not set it as you would other headers.  The status header is set as follows:</p>
			<pre class="php"><code>Output::$status = 404;</code></pre>
			<p>You simply set the <kbd>$status</kbd> variable to the status number for the request.</p>
		</article>

		<article>
			<h4>set_header($name, $value)</h4>
			<p>The <strong>set_header</strong> method allows set custom HTTP headers.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$name</kbd></th>
								<td><i>Required</i></td>
								<td>Name of the header to add</td>
							</tr>
							<tr>
								<th><kbd>$value</kbd></th>
								<td><i>Required</i></td>
								<td>The string that needs to be added to the HTTP header. It needs to be in the form "name: value", where 'name' needs to be identical to <kbd>$name</kbd>.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>void</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// We'll be outputting a PDF
Output::set_header('Content-type', 'Content-type: application/pdf');

// It will be called downloaded.pdf
Output::set_header('Content-Disposition', 'Content-Disposition: attachment; filename="downloaded.pdf"');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4>send_headers()</h4>
			<p>The <strong>send_headers</strong> method sents the set headers out to the browser, including the HTTP status of the request.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td><i>None</i></td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>void</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>Output::send_headers();</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
			<p>Note that you normally don't have to call this method manually. FuelPHP will take care of this as part of processing the request.</p>
		</article>

		<article>
			<h4>redirect($url = '', $method = 'location', $redirect_code = 302)</h4>
			<p>The <strong>redirect</strong> method offers different methods of redirecting to a new URL.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$url</kbd></th>
								<td><pre class="php"><code>''</code></pre></td>
								<td>URL to redirect to.</td>
							</tr>
							<tr>
								<th><kbd>$method</kbd></th>
								<td><pre class="php"><code>'location'</code></pre></td>
								<td>Redirection method to use. Supported are 'location' and 'refresh'.</td>
							</tr>
							<tr>
								<th><kbd>$redirect_code</kbd></th>
								<td><pre class="php"><code>302</code></pre></td>
								<td>HTTP status code to send back as part of the redirect.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>This method terminates the current script, it does not return.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>Output::redirect('http://example.com/home', 'refresh');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

	</section>

	<section id="footer">
		<p>
			<a href="http://fuelphp.com">Fuel PHP</a> is released under the MIT license.<br />
			&copy; 2010 - 2011 Fuel Development Team
		</p>
	</section>

</body>
</html>
